home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / bsktball.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  11KB  |  421 lines

  1. /***************************************************************************
  2.  
  3. Atari Basketball Driver
  4.  
  5. Note:  The original hardware uses the Player 1 and Player 2 Start buttons
  6. as the Jump/Shoot buttons.    I've taken button 1 and mapped it to the Start
  7. buttons to keep people from getting confused.
  8.  
  9. If you have any questions about how this driver works, don't hesitate to
  10. ask.  - Mike Balfour (mab22@po.cwru.edu)
  11. ***************************************************************************/
  12.  
  13. #include "driver.h"
  14. #include "vidhrdw/generic.h"
  15.  
  16. /* machine/bsktball.c */
  17. WRITE_HANDLER( bsktball_nmion_w );
  18. extern int bsktball_interrupt(void);
  19. WRITE_HANDLER( bsktball_ld1_w );
  20. WRITE_HANDLER( bsktball_ld2_w );
  21. READ_HANDLER( bsktball_in0_r );
  22. WRITE_HANDLER( bsktball_led1_w );
  23. WRITE_HANDLER( bsktball_led2_w );
  24.  
  25. /* vidhrdw/bsktball.c */
  26. extern unsigned char *bsktball_motion;
  27. extern void bsktball_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  28.  
  29.  
  30. /* sound hardware - temporary */
  31.  
  32. static int note_timer=255;
  33. static int note_count=256;
  34. static WRITE_HANDLER( bsktball_note_w );
  35. static void bsktball_note_32H(int foo);
  36. static void bsktball_noise_256H(int foo);
  37. static int init_timer=1;
  38. static int crowd_mask=0;
  39.  
  40. #define TIME_32H 10582*2
  41. #define TIME_256H TIME_32H*4
  42.  
  43. static WRITE_HANDLER( bsktball_note_w )
  44. {
  45.  
  46.     note_timer=data;
  47.     note_count=256;
  48.  
  49.     if ((init_timer) && (note_timer!=255))
  50.     {
  51.         timer_set (TIME_IN_NSEC(TIME_32H), 0, bsktball_note_32H);
  52.         init_timer=0;
  53.     }
  54. }
  55.  
  56. static int noise_b10=0;
  57. static int noise_a10=0;
  58. static int noise=0;
  59. static int noise_timer_set=0;
  60.  
  61. static WRITE_HANDLER( bsktball_noise_reset_w )
  62. {
  63.     noise_a10=0;
  64.     noise_b10=0;
  65.     DAC_data_w(2,0);
  66.  
  67.     if (!noise_timer_set)
  68.         timer_set (TIME_IN_NSEC(TIME_256H), 0, bsktball_noise_256H);
  69.     noise_timer_set=1;
  70. }
  71.  
  72. static void bsktball_noise_256H(int foo)
  73. {
  74.     int b10_input;
  75.     int a10_input;
  76.  
  77.     b10_input = (noise_b10 & 0x01) ^ (((~noise_a10) & 0x40) >> 6);
  78.     a10_input = (noise_b10 & 0x80) >> 7;
  79.  
  80.     noise_b10 = ((noise_b10 << 1) | b10_input) & 0xFF;
  81.     noise_a10 = ((noise_a10 << 1) | a10_input) & 0xFF;
  82.  
  83.     noise = (noise_a10 & 0x80) >> 7;
  84.  
  85.     if (noise)
  86.         DAC_data_w(2,crowd_mask);
  87.     else
  88.         DAC_data_w(2,0);
  89.  
  90.     timer_set (TIME_IN_NSEC(TIME_256H), 0, bsktball_noise_256H);
  91.     noise_timer_set=1;
  92. }
  93.  
  94. static void bsktball_note_32H(int foo)
  95. {
  96.     note_count--;
  97.  
  98.     if (note_count==note_timer)
  99.         note_count=256;
  100.  
  101.     if (note_count > ((256-note_timer)>>1)+note_timer)
  102.         DAC_data_w(0,255);            /* MB: Generate a square, 50% duty cycle _|-|_| */
  103.     else
  104.         DAC_data_w(0,0);
  105.  
  106.     if (note_timer!=255)
  107.         timer_set (TIME_IN_NSEC(TIME_32H), 0, bsktball_note_32H);
  108.     else
  109.         init_timer=1;
  110. }
  111.  
  112. static WRITE_HANDLER( bsktball_bounce_w )
  113. {
  114.     /* D0-D3 = crowd */
  115.     crowd_mask = (data & 0x0F) << 4;
  116.     if (noise)
  117.         DAC_data_w(2,crowd_mask);
  118.     else
  119.         DAC_data_w(2,0);
  120.  
  121.     /* D4 = bounce */
  122.     if (data & 0x10)
  123.         DAC_data_w(1,255);
  124.     else
  125.         DAC_data_w(1,0);
  126. }
  127.  
  128.  
  129. static struct MemoryReadAddress readmem[] =
  130. {
  131.     { 0x0000, 0x01ff, MRA_RAM }, /* Zero Page RAM */
  132.     { 0x0800, 0x0800, bsktball_in0_r },
  133.     { 0x0802, 0x0802, input_port_5_r },
  134.     { 0x0803, 0x0803, input_port_6_r },
  135.     { 0x1800, 0x1cff, MRA_RAM }, /* video ram */
  136.     { 0x2000, 0x3fff, MRA_ROM }, /* PROGRAM */
  137.     { 0xfff0, 0xffff, MRA_ROM }, /* PROM8 for 6502 vectors */
  138.     { -1 }    /* end of table */
  139. };
  140.  
  141. static struct MemoryWriteAddress writemem[] =
  142. {
  143.     { 0x0000, 0x01ff, MWA_RAM }, /* WRAM */
  144.     { 0x1000, 0x1000, MWA_RAM }, /* Timer Reset */
  145.     { 0x1010, 0x101f, bsktball_bounce_w }, /* Crowd Amp / Bounce */
  146.     { 0x1022, 0x1023, MWA_RAM }, /* Coin Counter */
  147.     { 0x1024, 0x1025, bsktball_led1_w }, /* LED 1 */
  148.     { 0x1026, 0x1027, bsktball_led2_w }, /* LED 2 */
  149.     { 0x1028, 0x1029, bsktball_ld1_w }, /* LD 1 */
  150.     { 0x102a, 0x102b, bsktball_ld2_w }, /* LD 2 */
  151.     { 0x102c, 0x102d, bsktball_noise_reset_w }, /* Noise Reset */
  152.     { 0x102e, 0x102f, bsktball_nmion_w }, /* NMI On */
  153.     { 0x1030, 0x103f, bsktball_note_w }, /* Music Ckt Note Dvsr */
  154.     { 0x1800, 0x1bbf, videoram_w, &videoram, &videoram_size }, /* DISPLAY */
  155.     { 0x1bc0, 0x1bff, MWA_RAM, &bsktball_motion },
  156.     { 0x2000, 0x3fff, MWA_ROM }, /* PROM1-PROM8 */
  157.     { -1 }    /* end of table */
  158. };
  159.  
  160. INPUT_PORTS_START( bsktball )
  161.     PORT_START    /* IN0 */
  162.     PORT_ANALOG( 0xFF, 0x00, IPT_TRACKBALL_X, 100, 10, 0, 0 ) /* Sensitivity, clip, min, max */
  163.  
  164.     PORT_START    /* IN0 */
  165.     PORT_ANALOG( 0xFF, 0x00, IPT_TRACKBALL_Y, 100, 10, 0, 0 )
  166.  
  167.     PORT_START    /* IN0 */
  168.     PORT_ANALOG( 0xFF, 0x00, IPT_TRACKBALL_X | IPF_PLAYER2, 100, 10, 0, 0 ) /* Sensitivity, clip, min, max */
  169.  
  170.     PORT_START    /* IN0 */
  171.     PORT_ANALOG( 0xFF, 0x00, IPT_TRACKBALL_Y | IPF_PLAYER2, 100, 10, 0, 0 )
  172.  
  173.     PORT_START        /* IN0 */
  174.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  175.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  176.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) /* SPARE */
  177.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) /* SPARE */
  178.     /* 0x10 - DR0 = PL2 H DIR */
  179.     /* 0x20 - DR1 = PL2 V DIR */
  180.     /* 0x40 - DR2 = PL1 H DIR */
  181.     /* 0x80 - DR3 = PL1 V DIR */
  182.  
  183.     PORT_START        /* IN2 */
  184.     PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
  185.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_TILT )
  186.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* SPARE */
  187.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* TEST STEP */
  188.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  189.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* COIN 0 */
  190.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) /* COIN 1 */
  191.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) /* COIN 2 */
  192.  
  193.     PORT_START        /* DSW */
  194.     PORT_DIPNAME( 0x07, 0x00, "Coin Mode" )
  195.     PORT_DIPSETTING(    0x07, DEF_STR( Free_Play ) )
  196.     PORT_DIPSETTING(    0x06, "2:30/Credit" )
  197.     PORT_DIPSETTING(    0x05, "2:00/Credit" )
  198.     PORT_DIPSETTING(    0x04, "1:30/Credit" )
  199.     PORT_DIPSETTING(    0x03, "1:15/Credit" )
  200.     PORT_DIPSETTING(    0x02, "0:45/Credit" )
  201.     PORT_DIPSETTING(    0x01, "0:30/Credit" )
  202.     PORT_DIPSETTING(    0x00, "1:00/Credit" )
  203.     PORT_DIPNAME( 0x18, 0x00, "Dollar Coin Mode" )
  204.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  205.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_4C ) )
  206.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
  207.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )
  208.     PORT_DIPNAME( 0x20, 0x00, "Cost" )
  209.     PORT_DIPSETTING(    0x20, "Two Coin Minimum" )
  210.     PORT_DIPSETTING(    0x00, "One Coin Minimum" )
  211.     PORT_DIPNAME( 0xC0, 0x00, "Language" )
  212.     PORT_DIPSETTING(    0xC0, "German" )
  213.     PORT_DIPSETTING(    0x80, "French" )
  214.     PORT_DIPSETTING(    0x40, "Spanish" )
  215.     PORT_DIPSETTING(    0x00, "English" )
  216. INPUT_PORTS_END
  217.  
  218. static struct GfxLayout charlayout =
  219. {
  220.     8,8,    /* 8*8 characters */
  221.     64,     /* 64 characters */
  222.     2,        /* 2 bits per pixel */
  223.     { 0, 8*0x800 },        /* bitplanes separated by $800 bytes */
  224.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  225.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  226.     8*8 /* every char takes 8 consecutive bytes */
  227. };
  228.  
  229. static struct GfxLayout motionlayout =
  230. {
  231.     8,32,    /* 8*32 characters */
  232.     64,     /* 64 characters */
  233.     2,        /* 2 bits per pixel */
  234.     { 0, 8*0x800 },        /* bitplanes separated by $800 bytes */
  235.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  236.     {    0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  237.         8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8,
  238.         16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8,
  239.         24*8, 25*8, 26*8, 27*8, 28*8, 29*8, 30*8, 31*8 },
  240.     32*8    /* every char takes 32 consecutive bytes */
  241. };
  242.  
  243. static struct GfxDecodeInfo gfxdecodeinfo[] =
  244. {
  245.     { REGION_GFX1, 0x0600, &charlayout,   0x00, 0x02 },
  246.     { REGION_GFX1, 0x0000, &motionlayout, 0x08, 0x40 },
  247.     { -1 } /* end of array */
  248. };
  249.  
  250.  
  251.  
  252. static unsigned char palette[] =
  253. {
  254.     0x00,0x00,0x00, /* BLACK */
  255.     0x80,0x80,0x80, /* LIGHT GREY */
  256.     0x50,0x50,0x50, /* DARK GREY */
  257.     0xff,0xff,0xff, /* WHITE */
  258. };
  259. static unsigned short colortable[] =
  260. {
  261.     /* Playfield */
  262.     0x01, 0x00, 0x00, 0x00,
  263.     0x01, 0x03, 0x03, 0x03,
  264.  
  265.     /* Motion */
  266.     0x01, 0x00, 0x00, 0x00,
  267.     0x01, 0x00, 0x01, 0x00,
  268.     0x01, 0x00, 0x02, 0x00,
  269.     0x01, 0x00, 0x03, 0x00,
  270.  
  271.     0x01, 0x01, 0x00, 0x00,
  272.     0x01, 0x01, 0x01, 0x00,
  273.     0x01, 0x01, 0x02, 0x00,
  274.     0x01, 0x01, 0x03, 0x00,
  275.  
  276.     0x01, 0x02, 0x00, 0x00,
  277.     0x01, 0x02, 0x01, 0x00,
  278.     0x01, 0x02, 0x02, 0x00,
  279.     0x01, 0x02, 0x03, 0x00,
  280.  
  281.     0x01, 0x03, 0x00, 0x00,
  282.     0x01, 0x03, 0x01, 0x00,
  283.     0x01, 0x03, 0x02, 0x00,
  284.     0x01, 0x03, 0x03, 0x00,
  285.  
  286.     0x01, 0x00, 0x00, 0x01,
  287.     0x01, 0x00, 0x01, 0x01,
  288.     0x01, 0x00, 0x02, 0x01,
  289.     0x01, 0x00, 0x03, 0x01,
  290.  
  291.     0x01, 0x01, 0x00, 0x01,
  292.     0x01, 0x01, 0x01, 0x01,
  293.     0x01, 0x01, 0x02, 0x01,
  294.     0x01, 0x01, 0x03, 0x01,
  295.  
  296.     0x01, 0x02, 0x00, 0x01,
  297.     0x01, 0x02, 0x01, 0x01,
  298.     0x01, 0x02, 0x02, 0x01,
  299.     0x01, 0x02, 0x03, 0x01,
  300.  
  301.     0x01, 0x03, 0x00, 0x01,
  302.     0x01, 0x03, 0x01, 0x01,
  303.     0x01, 0x03, 0x02, 0x01,
  304.     0x01, 0x03, 0x03, 0x01,
  305.  
  306.     0x01, 0x00, 0x00, 0x02,
  307.     0x01, 0x00, 0x01, 0x02,
  308.     0x01, 0x00, 0x02, 0x02,
  309.     0x01, 0x00, 0x03, 0x02,
  310.  
  311.     0x01, 0x01, 0x00, 0x02,
  312.     0x01, 0x01, 0x01, 0x02,
  313.     0x01, 0x01, 0x02, 0x02,
  314.     0x01, 0x01, 0x03, 0x02,
  315.  
  316.     0x01, 0x02, 0x00, 0x02,
  317.     0x01, 0x02, 0x01, 0x02,
  318.     0x01, 0x02, 0x02, 0x02,
  319.     0x01, 0x02, 0x03, 0x02,
  320.  
  321.     0x01, 0x03, 0x00, 0x02,
  322.     0x01, 0x03, 0x01, 0x02,
  323.     0x01, 0x03, 0x02, 0x02,
  324.     0x01, 0x03, 0x03, 0x02,
  325.  
  326.     0x01, 0x00, 0x00, 0x03,
  327.     0x01, 0x00, 0x01, 0x03,
  328.     0x01, 0x00, 0x02, 0x03,
  329.     0x01, 0x00, 0x03, 0x03,
  330.  
  331.     0x01, 0x01, 0x00, 0x03,
  332.     0x01, 0x01, 0x01, 0x03,
  333.     0x01, 0x01, 0x02, 0x03,
  334.     0x01, 0x01, 0x03, 0x03,
  335.  
  336.     0x01, 0x02, 0x00, 0x03,
  337.     0x01, 0x02, 0x01, 0x03,
  338.     0x01, 0x02, 0x02, 0x03,
  339.     0x01, 0x02, 0x03, 0x03,
  340.  
  341.     0x01, 0x03, 0x00, 0x03,
  342.     0x01, 0x03, 0x01, 0x03,
  343.     0x01, 0x03, 0x02, 0x03,
  344.     0x01, 0x03, 0x03, 0x03,
  345.  
  346. };
  347. static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
  348. {
  349.     memcpy(game_palette,palette,sizeof(palette));
  350.     memcpy(game_colortable,colortable,sizeof(colortable));
  351. }
  352.  
  353.  
  354. static struct DACinterface dac_interface =
  355. {
  356.     3,
  357.     { 100, 100, 100 }
  358. };
  359.  
  360.  
  361. static struct MachineDriver machine_driver_bsktball =
  362. {
  363.     /* basic machine hardware */
  364.     {
  365.         {
  366.             CPU_M6502,
  367.             750000,        /* 750 KHz */
  368.             readmem,writemem,0,0,
  369.             bsktball_interrupt,8
  370.         }
  371.     },
  372.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  373.     1,    /* single CPU, no need for interleaving */
  374.     0,
  375.  
  376.     /* video hardware */
  377.     32*8, 28*8, { 0*8, 32*8-1, 0*8, 28*8-1 },
  378.     gfxdecodeinfo,
  379.     sizeof(palette) / sizeof(palette[0]) / 3, sizeof(colortable) / sizeof(colortable[0]),
  380.     init_palette,
  381.  
  382.     VIDEO_TYPE_RASTER,
  383.     0,
  384.     generic_vh_start,
  385.     generic_vh_stop,
  386.     bsktball_vh_screenrefresh,
  387.  
  388.     /* sound hardware */
  389.     0,0,0,0,
  390.     {
  391.         {
  392.             SOUND_DAC,
  393.             &dac_interface
  394.         }
  395.     }
  396. };
  397.  
  398.  
  399. /***************************************************************************
  400.  
  401.   Game driver(s)
  402.  
  403. ***************************************************************************/
  404.  
  405. ROM_START( bsktball )
  406.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
  407.     ROM_LOAD( "034765.d1",    0x2000, 0x0800, 0x798cea39 )
  408.     ROM_LOAD( "034764.c1",    0x2800, 0x0800, 0xa087109e )
  409.     ROM_LOAD( "034766.f1",    0x3000, 0x0800, 0xa82e9a9f )
  410.     ROM_LOAD( "034763.b1",    0x3800, 0x0800, 0x1fc69359 )
  411.     ROM_RELOAD(               0xf800, 0x0800 )
  412.  
  413.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  414.     ROM_LOAD( "034757.a6",    0x0000, 0x0800, 0x010e8ad3 )
  415.     ROM_LOAD( "034758.b6",    0x0800, 0x0800, 0xf7bea344 )
  416. ROM_END
  417.  
  418.  
  419.  
  420. GAME( 1979, bsktball, 0, bsktball, bsktball, 0, ROT0, "Atari", "Basketball" )
  421.